package com.cx.mall.demo.controller;

import com.cx.mall.demo.entity.Children;
import com.cx.mall.demo.entity.Dog;
import com.cx.mall.demo.entity.Person;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.Mapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class PersonController {
    @Autowired  // 注解：从容器中取Person对象
    private Person person;
    @Autowired
    private Dog dog;
    @Autowired
    private Children child;
    @GetMapping("/person") // 映射URI
    public String getPerson(){
        return person.toString();
    }
    @GetMapping ("/dog")
    public String getDog(){

        return dog.toString();
    }
    @GetMapping("/children")
    public  String getChildren(){
        child.setName("小花");
        return child.toString();
    }
}